<?php if( !defined( '_VALID_MOS' ) && !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' );
/**
*
* @package  RealEstateManager
* @copyright 2011 Andrey Kvasnevskiy-OrdaSoft(akbet@mail.ru); Rob de Cleen(rob@decleen.com) 
* Homepage: http://www.ordasoft.com
* @version: 2.1 Free $
*
**/

require_once($mosConfig_absolute_path."/libraries/joomla/plugin/helper.php");
require_once ($mosConfig_absolute_path."/administrator/includes/toolbar.php");
require_once ($mosConfig_absolute_path."/libraries/joomla/html/toolbar.php");

require_once($mosConfig_absolute_path."/components/com_realestatemanager/realestatemanager.php");
require_once($mosConfig_absolute_path."/administrator/components/com_realestatemanager/menubar_ext.php");

$mosConfig_live_site = JURI::root(true); //for 1.6
$GLOBALS['mosConfig_live_site'] = $mosConfig_live_site;
$GLOBALS['mosConfig_absolute_path'] = $mosConfig_absolute_path;//for 1.6

// for J 1.6
  $mainframe = JFactory::getApplication(); 
  $GLOBALS['mainframe'] = $mainframe; 

  $templateDir = JPATH_THEMES.DS.JFactory::getApplication()->getTemplate().DS;  
  $GLOBALS['templateDir'] = $templateDir;
  $doc =& JFactory::getDocument();  
  $GLOBALS['doc'] = $doc; 


$g_item_count = 0;
class HTML_realestatemanager
{
    function positions($position){
        JPluginHelper::importPlugin('content');
        $dispatcher = & JDispatcher::getInstance();
        $err_state = ini_get('display_errors');
        ini_set('display_errors', 'Off');
        $plug_row->text = $position; // load the var into plugin_row object
        $offset = 0;
        $results = $dispatcher->trigger('onContentPrepare', array ('com_vehiclemanager', &$plug_row, &$plug_params, $offset)); //run mambot onPrepareContent on plug_row object
        echo $plug_row->text; //echo new content out
        ini_set('display_errors', $err_state);
    }

	function showRentRequest( & $houses, & $currentcat, & $params, & $tabclass, & $catid, & $sub_categories,$is_exist_sub_categories){
    $pageNav = new JPagination(0, 0, 0);

		HTML_realestatemanager::displayHouses($houses, $currentcat, $params, $tabclass, $catid, $sub_categories, $is_exist_sub_categories,$pageNav);
		// add the formular for send to :-)
	}


function displayHouses(&$rows, $currentcat, &$params, $tabclass, $catid, $categories,$is_exist_sub_categories,&$pageNav= null)
{
    $session = &JFactory::getSession();
    $arr = $session->get("array","default");

    global $hide_js, $Itemid,$mosConfig_live_site,$mosConfig_absolute_path,$database, $doc;
    global $limit, $total, $limitstart, $task, $paginations, $mainframe,$realestatemanager_configuration;

    //$doc->addStyleSheet( $mosConfig_live_site.'/administrator/components/com_realestatemanager/includes/realestatemanager.css' );
	//    $doc->addStyleSheet( $mosConfig_live_site.'/includes/js/calendar/calendar-mos.css' );
	//    $doc->addScript($mosConfig_live_site.'/includes/js/mambojavascript.js');
	//    $doc->addScript($mosConfig_live_site.'/includes/js/calendar/calendar.js');
	//    $doc->addScript($mosConfig_live_site.'/includes/js/calendar/lang/calendar-en-GB.js');
	//    $doc->addScript($mosConfig_live_site.'/includes/js/overlib_mini.js');
	?>

	<script type="text/javascript">
	function rent_request_submitbutton() {
		var form = document.userForm;
		if (form.user_name.value == "") {
			alert( "<?php echo _REALESTATE_MANAGER_INFOTEXT_JS_RENT_REQ_NAME; ?>" );				
		} else if (form.user_email.value == "" || !isValidEmail(form.user_email.value)) {
			alert( "<?php echo _REALESTATE_MANAGER_INFOTEXT_JS_RENT_REQ_EMAIL;?>" );
		} else if (form.user_mailing == "") {       
			alert( "<?php echo _REALESTATE_MANAGER_INFOTEXT_JS_RENT_REQ_MAILING;?>" );
		} else if ((form.rent_until.value == "") || (form.rent_until.value < form.rent_from.value)) {  
			alert( "<?php echo _REALESTATE_MANAGER_INFOTEXT_JS_RENT_REQ_UNTIL;?>" );
		} else {
			form.submit();
		}
	}
	
	function isValidEmail(str) {
		return (str.indexOf("@") > 1);
	}

    function allreordering(){
        if(document.orderForm.order_direction.value=='asc')
          document.orderForm.order_direction.value='desc';
        else document.orderForm.order_direction.value='asc';

        document.orderForm.submit();
    }
	</script>

	<div id="listing">
	
		<h2><?php echo $currentcat->header; ?></h2>
		
		<?php 
		if (count($rows) > 0) {
			$sort_arr['order_field'] = $params->get('sort_arr_order_field');
			$sort_arr['order_direction'] = $params->get('sort_arr_order_direction');
			?>
			<div class="orderby">
				<form method="POST" action="<?php echo sefRelToAbs($_SERVER["REQUEST_URI"]);?>" name="orderForm">
				
				<?php echo _REALESTATE_MANAGER_LABEL_ORDER_BY;?> 
				<select size="1" class="inputbox" onchange="javascript:document.orderForm.submit();" id="order_field" name="order_field">
				<option  value="date" <?php if($sort_arr['order_field'] == "date") echo 'selected="selected"'; ?> >  <?php echo _REALESTATE_MANAGER_LABEL_DATE; ?> </option>
				<option value="price" <?php if($sort_arr['order_field'] == "price") echo 'selected="selected"'; ?> > <?php echo _REALESTATE_MANAGER_LABEL_PRICE; ?></option>
				<option value="htitle" <?php if($sort_arr['order_field'] == "htitle") echo 'selected="selected"'; ?> > <?php echo _REALESTATE_MANAGER_LABEL_TITLE; ?></option>
				</select>
				
				<select class="inputbox" onchange="javascript:document.orderForm.submit();" id="order_direction" name="order_direction">
				<option value="asc" <?php if($sort_arr['order_direction'] == "asc") echo 'selected="selected"'; ?>>Ascendente</option>
				<option value="desc" <?php if($sort_arr['order_direction'] == "desc") echo 'selected="selected"'; ?>>Descendente</option>
				</select>
				</form>
			</div>
			
			<div class="list">
            	<div class="clear">
					<?php
                    $property_type['townhouse'] = _REALESTATE_MANAGER_OPTION_TOWNHOUSE;
                    $property_type['apartment'] = _REALESTATE_MANAGER_OPTION_APARTMENT;
                    $property_type['warehouse'] = _REALESTATE_MANAGER_OPTION_WAREHOUSE;
                    $property_type['office'] = _REALESTATE_MANAGER_OPTION_OFFICE;
                    $property_type['garage'] = _REALESTATE_MANAGER_OPTION_GARAGE;
                    $property_type['store'] = _REALESTATE_MANAGER_OPTION_STORE;
                    $property_type['houseind'] = _REALESTATE_MANAGER_OPTION_IND_HOUSE;
					$property_type['housegem'] = _REALESTATE_MANAGER_OPTION_HOUSE_GEM;
					$property_type['housegav'] = _REALESTATE_MANAGER_OPTION_HOUSE_GAV;
					$property_type['houseband'] = _REALESTATE_MANAGER_OPTION_HAOUSE_BAND;
                    $property_type['parking'] = _REALESTATE_MANAGER_OPTION_PARKING;
                    $property_type['pavillion'] = _REALESTATE_MANAGER_OPTION_PAVILLION;
					$property_type['building'] = _REALESTATE_MANAGER_OPTION_BUILDING;
                    $property_type['farm'] = _REALESTATE_MANAGER_OPTION_FARM;
                    $property_type['smallfarm'] = _REALESTATE_MANAGER_OPTION_SMALLFARM;
					$property_type['rest'] = _REALESTATE_MANAGER_OPTION_REST;
                    $property_type['land'] = _REALESTATE_MANAGER_OPTION_LAND;
        
                    $available = false;
                    $k = 0;
                    $total = count($rows);
                    $col = 1;
                    foreach ($rows as $row) {
                        $k++;
                        $tmphouse = new mosRealEstateManager($database);
                        $tmphouse->load($row->id);
                        $tmphouse->setCatIds();
                        
                        $link = 'index.php?option=com_realestatemanager&amp;task=view&amp;id='. $row->id . '&amp;catid='. $tmphouse->catid[0] .'&amp;Itemid='. $Itemid;
                        $house = $row;
                        $imageURL = $house->image_link;
                        ?>
                        <div class="property col<?php echo $col;?>">
                            <div class="image">
                            <?php
                            if($imageURL != ''){
                                $file_pth = pathinfo($house->image_link);
                                $file_type = '.' . $file_pth['extension'];
                                if(array_key_exists('filename', $file_pth)) 
                                    $file_name = $file_pth['filename'];
                                else 
                                    $file_name = substr($imageURL, 0, strlen($imageURL) - strlen($file_pth['extension']) - 1);
                                
                                ?>
                                <a href="<?php echo $link;?>"><img src="<?php echo $mosConfig_live_site.'/components/com_realestatemanager/photos/'.$file_name.$file_type;?>" border="0" class="little" /></a>
                                <?php
                            } else{
                                ?>
                                <a href="<?php echo $link;?>"><img src="./components/com_realestatemanager/images/no-img_eng.gif" border="0" /></a>
                                <?php
                            }
                            ?>
                            </div>
                            
                            <div class="info">
                                <a class="title" href="<?php echo $link;?>"><?php echo $row->htitle; ?></a>
                                <?php echo $house->category_titel; //objectivo ?>
                                <?php echo $property_type[$house->property_type]; ?> 
                                <?php
                                if($house->typology != '0' && $house->typology != 'sem') {
									echo strtoupper($house->typology);
								}
							    ?>
                                
                                <br />
                                <?php 
                                echo $house->council_txt;
                                if(isset($house->council_txt) && isset($house->parish_txt))
                                    echo ", ";
                                echo $house->parish_txt;
                                ?>
                                <br />
                                <strong><?php echo number_format($row->price, 0, ",", "."), ' €'; ?></strong>
                            </div>
                        </div>
                        <?php
                        $col++;
                        if($col > 2){
                            $col = 1;
							echo "</div><div class=\"clear\">";
						}
                    } 
                    ?>
				</div>
			</div>
			<?php
		}
		?>
	</div>
	
	<div class="pager-container">
		<div class="pager">
			<?php echo $pageNav->getPagesLinks( ); ?>
		</div>
	</div>
	
	<?php
}
	  

  
    
	/**
	 * Displays the house
	 */
	function displayHouse( & $house, & $tabclass, & $params, & $currentcat, & $rating, & $house_photos,$id, $catid) 
  {

		global $hide_js,$mainframe, $Itemid, $realestatemanager_configuration, $mosConfig_live_site, $mosConfig_absolute_path, $my, $doc;

?>

    <script src="<?php echo $mosConfig_live_site.'/components/com_realestatemanager/lightbox/js/jQuerREL-1.2.6.js'; ?>" 
type="text/javascript"></script>
    <script type="text/javascript">jQuerREL.noConflict();</script> 
    <script src="<?php echo $mosConfig_live_site.'/components/com_realestatemanager/lightbox/js/jquery.lightbox.js'; ?>" 
type="text/javascript"></script>
    <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=<?php echo $realestatemanager_configuration['google_map']['key']; ?>"
    type="text/javascript">
  </script>
<?php
    $doc->addStyleSheet( $mosConfig_live_site.'/components/com_realestatemanager/lightbox/css/lightbox.css' );
    $doc->addStyleSheet( $mosConfig_live_site.'/administrator/components/com_realestatemanager/includes/realestatemanager.css');
//////////TABS
		$doc->addStyleSheet( $mosConfig_live_site.'/components/com_realestatemanager/TABS/tabcontent.css');

		$doc->addScript(  $mosConfig_live_site.'/components/com_realestatemanager/TABS/tabcontent.js' );
////////////Adding google map
$realestatemanager_configuration=$GLOBALS['realestatemanager_configuration'];

$doc->setTitle($currentcat->header);

?>
<script type="text/javascript">
jQuerREL(document).ready(function(){
  jQuerREL("#gallery a").lightbox();
    jQuerREL.Lightbox.construct({
      "speed": 500,
      "show_linkback": true,
      "keys": {
      close:  "q",
      prev: "z",
      next: "x"
    },
    "opacity": 0.3,
    files: {
      images: {
        prev:   '<?php echo $mosConfig_live_site?>/components/com_realestatemanager/lightbox/images/prev.gif',
        next:   '<?php echo $mosConfig_live_site?>/components/com_realestatemanager/lightbox/images/next.gif',
        blank:    '<?php echo $mosConfig_live_site?>/components/com_realestatemanager/lightbox/images/blank.gif',
        loading:  '<?php echo $mosConfig_live_site?>/components/com_realestatemanager/lightbox/images/loading.gif'
      }
    }
    });
});
</script> 

<script type="text/javascript">  
    var map;

	function initialize() {
		if (GBrowserIsCompatible()) {
			map = new GMap2(document.getElementById("map_canvas"));
			map.setCenter(new GLatLng(<?php if($house->hlatitude) echo $house->hlatitude;else echo 0; ?>, 
										<?php if($house->hlongitude) echo $house->hlongitude;else echo 0; ?>),
										12);
		
			/*set type map: G_HYBRID_MAP, G_NORMAL_MAP, G_SATELLITE_MAP*/
			map.setMapType(G_HYBRID_MAP);  
			//Установка маркера с координатами дома	
			<?php if ($house->hlatitude && $house->hlongitude) 	
			{ ?>  
				var marker = new GMarker(new GLatLng(<?php echo $house->hlatitude; ?>, <?php echo $house->hlongitude; ?>),false);
				map.addOverlay( marker );	
			<?php } ?>   
			
			/////////////////////////////////////////////////////
			var mapTypeControl = new GMapTypeControl();
			/*задание координат где выводить кнопку с типами карт*/
			var topRight = new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(5,5));
			map.addControl(mapTypeControl, topRight); /* topRight вывод самих кнопок*/
			/*GSmallMapControl() -- Создает контроль с кнопками, +- право/лево в  угол*/
			map.addControl(new GSmallMapControl());
		}
	}
$(document).ready(function() {
	initialize();
});
</script>
<!--End google map.Желательно выгружать google с памяти с помощью функции onunload="GUnload()"   -->

<div id="overDiv" ></div>
<script type="text/javascript" language="Javascript" src="./includes/js/overlib_mini.js">
</script>
<?php   

                JPluginHelper::importPlugin('content');
		$dispatcher = & JDispatcher::getInstance();	?>  
		<script language="javascript" type="text/javascript">

		function review_submitbutton() { 			
			var form = document.review;
			// do field validation
			var rating_checked = false; 
			for (c = 0;  c < form.rating.length; c++){
				if (form.rating[c].checked){
					rating_checked = true;
				} 
			}
			if (form.title.value == "") {
				alert( "<?php echo _REALESTATE_MANAGER_INFOTEXT_JS_REVIEW_TITLE; ?>" );
			} else if (form.comment == "") {
				alert( "<?php echo _REALESTATE_MANAGER_INFOTEXT_JS_REVIEW_COMMENT;?>" );
			} else if (!rating_checked) {				
				alert( "<?php echo _REALESTATE_MANAGER_INFOTEXT_JS_REVIEW_RATING;?>" );
			} else {
				form.submit();
			}
		}
//*****************   begin add for show/hiden button "Add review" ********************
			function button_hidden( is_hide ) {
				var el = document.getElementById('button_hidden_review');
				var el2 = document.getElementById('hidden_review');
				if(is_hide){
					el.style.display = 'none';
					el2.style.display = 'block';
				} else {
					el.style.display = 'block';
					el2.style.display = 'none';
				}
			}


		function buying_request_submitbutton() {
			var form = document.buying_request;
			if (form.customer_name.value == "") {
				alert( "<?php echo _REALESTATE_MANAGER_INFOTEXT_JS_BUY_REQ_NAME; ?>" );
			} else if (form.customer_email.value == ""|| !isValidEmail(form.customer_email.value)) {
				alert( "<?php echo _REALESTATE_MANAGER_INFOTEXT_JS_BUY_REQ_EMAIL;?>" );
			} else if (form.customer_phone.value == ""||!isValidPhoneNumber(form.customer_phone.value)){ 			  				
				alert( "<?php echo _REALESTATE_MANAGER_INFOTEXT_JS_BUY_REQ_PHONE;?>" );
			} else {
				form.submit();
			}
		}
		function isValidPhoneNumber(str){

		myregexp = new RegExp("^([_0-9() -;,]*)$");
			mymatch = myregexp.exec(str);
			//alert(mymatch);exit							

			if(str == "")
				return false;
			if(mymatch != null)
				return true;
			return false;
		}
		function isValidEmail(str) {
			return (str.indexOf("@") > 1);
		}
		
//****************   end add for show/hiden button "Add buying"   *********************
			function buy_house( is_hide ) 
			{
				var el  = document.getElementById('hidden_buying');
				var el2 = document.getElementById('show_buying');
				if( is_hide ) {
					el.style.display = 'none';
					el2.style.display = 'block';
				} else {
					el.style.display = 'block';
					el2.style.display = 'none';
				}
			}
		</script>
	
	
	
	
	<div id="property_file">
		<h2>Ficha do Imóvel</h2>
		
		<div class="col1">
			<h3><?php echo $currentcat->header; ?></h3>
	
			<div class="main_image">
				<?php 
				$imageURL = $house->image_link;
				
				if($imageURL != ''){
					?>
					<img src="<?php echo $mosConfig_live_site;?>/components/com_realestatemanager/photos/<?php echo $imageURL;?>">
					<?php
				} 
				?>
			</div>
			
			<div class="characteristics">
				<table cellpadding="0" cellspacing="0" border="0">
				<tr>
					<td class="label">Referência:</td>
					<td><?php echo $house->houseid; ?></td>
				</tr>
				<tr>
					<td class="label">Objectivo:</td>
					<td><?php echo $house->category_title; //objectivo ?></td>
				</tr>
				<tr>
					<td class="label">Tipo de imóvel:</td>
					<td><?php echo $house->property_type; ?></td>
				</tr>
				<tr>
					<td class="label">Tipologia:</td>
					<td><?php echo $house->typology;?></td>
				</tr>
				<?php
				if($house->price > 0){ ?>
					<tr>
						<td class="label">Preço:</td>
						<td><?php echo number_format($house->price, 0, ",", ".");?> €</td>
					</tr>
					<?php
				} ?>
				<tr>
					<td class="label">Distrito:</td>
					<td><?php echo $house->district_txt;?></td>
				</tr>
				<tr>
					<td class="label">Concelho:</td>
					<td><?php echo $house->council_txt;?></td>
				</tr>
				<tr>
					<td class="label">Freguesia:</td>
					<td><?php echo $house->parish_txt;?></td>
				</tr>
				<?php
				if(isset($house->hlocation)){ ?>
					<tr>
						<td class="label">Endereço:</td>
						<td><?php echo $house->hlocation; ?></td>
					</tr>
					<?php
				} ?>
				<?php  if(trim($house->bathrooms)){ ?>
					<tr>
						<td class="label">Nº de wcs:</td>
						<td><?php echo $house->bathrooms; ?></td>
					</tr>
				<?php } ?>
				<?php  if(trim($house->bedrooms )){ ?>
				<tr>
					<td class="label">Nº de quartos:</td>
					<td><?php echo $house->bedrooms; ?></td>
				</tr>
				<?php } ?>
				<?php if(isset($house->area)){ ?>
				<tr>
					<td class="label">Área:</td>
					<td><?php echo $house->area; ?></td>
				</tr>
				<?php } ?>
				<?php  if(trim($house->year)){ ?>
				<tr>
					<td class="label">Ano:</td>
					<td><?php echo $house->year; ?></td>
				</tr>
				<?php } ?>
				
				
				
				<?php  if(trim($house->broker)){ ?>
				<tr>
					<td class="label">Vendedor:</td>
					<td><?php echo $house->broker; ?></td>
				</tr>
				<?php } ?>
				<?php  if(trim($house->contacts)){ ?>
				<tr>
					<td class="label">Contacto:</td>
					<td><?php echo $house->contacts; ?></td>
				</tr>
				<?php } ?>
				<tr>
					<td class="label"></td>
					<td></td>
				</tr>
				<tr>
					<td class="label"></td>
					<td></td>
				</tr>
				</table>
			</div>
			
			<div class="desc">
				<h4>Descrição</h4>
				<?php 
				if(trim($house->description)){ 
					echo $house->description;
				} ?>
			</div>
		</div>
		<div class="col2">
			<!-- photos -->
			<?php if(count($house_photos) > 0) { ?>
				<h3><?php echo _REALESTATE_MANAGER_HEADER_PHOTOGALERY;?></h3>
				<table class="basictable">
				<tr>
				<td>
				<?php
				for($i = 0; $i < count($house_photos); $i++)
				{
					if($i > 0 && $i % 5 == 0) 
						echo "</td></tr><tr><td>";
					$photo_pth=pathinfo($house_photos[$i]->main_img);
					$photo_type='.'.$photo_pth['extension'];
					$photo_name=basename($house_photos[$i]->main_img,$photo_type);
					?>
					<a class="thumbnail" href="<?php echo sefRelToAbs( $mosConfig_live_site."/components/com_realestatemanager/photos/".$house_photos[$i]->main_img);?>" rel="lightbox[img]" title="photo" >
					<img src="<?php echo sefRelToAbs( $mosConfig_live_site."/components/com_realestatemanager/photos/".$photo_name."_mini".$photo_type); ?>" />
					</a>
					<?php
				}
				?>
				</td>
				</tr>
				</table>
			<?php } ?>
			<!-- // photos -->
			
			<!-- map -->
			<?php 
			if ($house->hlatitude && $house->hlongitude){ ?>
				<h3 style="margin-top:20px">Mapa</h3>
				<table class="basictable">
				<tr>
				<td>
					<strong>Latitude:</strong>
				</td>
				<td>
					<?php echo $house->hlatitude; ?> 
				</td>
				</tr>
				<tr>	
				<td>
					<strong>Longitude:</strong>
				</td>
				<td>
					<?php echo $house->hlongitude;?>
				</td>
				</tr>	
				</table>
				<div id="map_canvas" style="width:450px; height:300px;"></div>
			<?php } ?>
			<!-- //map -->
			
		</div>
	</div>
 	<?php 
}  //end function

  
	/**
	* Display links to categories
	*/
function showCategories( &$params, &$categories, &$catid, &$tabclass , &$currentcat)
{
	global $hide_js, $Itemid, $acl, $mosConfig_live_site, $my,$mainframe, $doc;

  $doc->addStyleSheet( $mosConfig_live_site.'/administrator/components/com_realestatemanager/includes/realestatemanager.css' );

		?>
		<div class="componentheading<?php echo $params->get( 'pageclass_sfx' ); ?>">
			<?php echo $currentcat->header; ?>
		</div>
		<table border="0" cellpadding="4" cellspacing="0" width="100%" class="basictable" >
			<tr>
				<td>
					<?php echo $currentcat->descrip; ?>
				</td>     
        <td width="120" align="center">
          <img src="./components/com_realestatemanager/images/rem_logo.png" align="right" alt="Real Estate Manager logo"/>
        </td>
     </tr>
    </table>

		<form action="<?php echo sefRelToAbs("index.php?option=com_realestatemanager&Itemid=". $Itemid); ?>" method="post" name="adminForm">
		<?php	
				
		if($params->get('show_search')){
		?>
			<div class="componentheading<?php echo $params->get( 'pageclass_sfx' ); ?>">
			<table width="100%" border="0" cellspacing="0" cellpadding="0" class="basictable">
				<tr>
					<td width="50%">&nbsp;
					</td>
					<td align="right" width="50%">	
<?php $link = 'index.php?option=com_realestatemanager&amp;task=show_search&amp;catid='. $catid. '&amp;Itemid='. $Itemid;
					?>
					<a href="<?php echo sefRelToAbs($link); ?>" >
					&nbsp;<img align="right" src="./components/com_realestatemanager/images/search.gif" alt="Search" border="0" align="left"/>                              &nbsp;<?php echo _REALESTATE_MANAGER_LABEL_SEARCH; ?></a>
					</td>
				</tr>
				<tr>
					<td colspan="2">&nbsp;
					</td>
        </tr>
			</table>
		</div>
		<?php	
		}

			HTML_realestatemanager::listCategories($params, $categories, $catid, $tabclass , $currentcat);
		?>
			<table width="100%" border="0" cellspacing="0" cellpadding="0" class="basictable">
				<tr>
					<td width="50%">&nbsp;
						
					</td>
					<td width="50%">
						<?php		
							mosHTML::BackButton ( $params, $hide_js ); 
						?>
					</td>
				</tr>
			</table>
 		</form>
<?php /*?> <div style="text-align: center;"><a href="http://ordasoft.com" style="font-size: 10px;">Powered by OrdaSoft!</a></div><?php */?>
<?php
}
  
	function listCategories( &$params, $cat_all, $catid, $tabclass , $currentcat) {
  

		global $Itemid,$mosConfig_live_site ;	
    global $doc;

    $doc->addStyleSheet( $mosConfig_live_site.'/administrator/components/com_realestatemanager/includes/realestatemanager.css' );
    
    ?>
		<table width="100%" border="0" cellspacing="0" cellpadding="0" class="basictable">
		<tr>
			<td colspan="1" height="20" width="90%" class="sectiontableheader<?php echo $params->get( 'pageclass_sfx' ); ?>">
			<?php echo _REALESTATE_MANAGER_LABEL_CATEGORY;?>
			</td>
			<td height="20" width="10%" class="sectiontableheader<?php echo $params->get( 'pageclass_sfx' ); ?>">
			<?php echo _REALESTATE_MANAGER_LABEL_HOUSES;?> 
			</td>	
		</tr>
		<tr>
			<td colspan="3">
			<?php
			HTML_realestatemanager::showInsertSubCategory($catid, $cat_all, $params, $tabclass, $Itemid, 0);?>
			</td>
		</tr>
		<tr>
			<td colspan="3">&nbsp;
				
			</td>
		</tr>
		</table>
<?php	
	}
 
/*
* function for show subcategory
*/
function showInsertSubCategory($id, $cat_all, $params, $tabclass, $Itemid, $deep) {
	global $g_item_count,$realestatemanager_configuration,$mosConfig_live_site ;
  
    global $doc;

    $doc->addStyleSheet( $mosConfig_live_site.'/administrator/components/com_realestatemanager/includes/realestatemanager.css' );
  
	$deep++;
	for ($i = 0; $i < count($cat_all); $i++) {
	    if ( ($id == $cat_all[$i]->parent_id) && ($cat_all[$i]->display == 1) ) {
		$g_item_count++;

		$link = 'index.php?option=com_realestatemanager&amp;task=showCategory&amp;catid='. $cat_all[$i]->id .'&amp;Itemid='. $Itemid; ?>
		<table width="100%" border="0" cellspacing="0" cellpadding="0" class="basictable">
			<tr class="<?php echo $tabclass[($g_item_count%2)]; ?>">
				<td width="1%">
					<?php
					if ($deep != 1 ) {
					   $jj = $deep;
					   while ($jj--){echo "&nbsp;&nbsp;&nbsp;&nbsp;";}
					   echo "&nbsp;|_";
					}
					?>
				</td>
				<td width="9%">
				<?php
					if ( ($params->get( 'show_cat_pic')) && ($cat_all[$i]->image != "")) {?>
					   <img src="./images/stories/<?php echo $cat_all[$i]->image;?>" alt="picture for subcategory" height="48" width="48" />&nbsp;
				<?php
					} else  {?>
						<img src="./components/com_realestatemanager/images/folder.png" alt="picture for subcategory" height="48" width="48" />&nbsp;
					  <?php }?>
				</td>
				<td width="80%">	
					<a href="<?php echo sefRelToAbs( $link ); ?>" class="category<?php echo $params->get( 'pageclass_sfx' ); ?>">
					<?php echo $cat_all[$i]->title;?>
					</a>					
				</td>
				<td  align="left" width="10%">				
					<?php if ($cat_all[$i]->houses == '') echo "0";else echo $cat_all[$i]->houses;?>
				</td>
			</tr>
		</table>
		<?php
if($realestatemanager_configuration['subcategory']['show']) HTML_realestatemanager::showInsertSubCategory($cat_all[$i]->id, $cat_all, $params, $tabclass, $Itemid, $deep);

	    }//end if ($id == $cat_all[$i]->parent_id)
//	    $z = 1 - $z;
	}//end for(...)	
}//end function showInsertSubCategory($id, $cat_all)




function showSearchHouses( $params, $currentcat, $clist , $option)
{
global $hide_js, $Itemid,$mainframe,$mosConfig_live_site, $doc;
	$doc->addScript($mosConfig_live_site.'/includes/js/calendar/calendar.js');
	$doc->addScript($mosConfig_live_site.'/includes/js/calendar/lang/calendar-en-GB.js');
	$doc->addScript($mosConfig_live_site.'/includes/js/joomla.javascript.js');
  $doc->addStyleSheet($mosConfig_live_site.'/includes/js/calendar/calendar-mos.css');	
  $doc->addStyleSheet( $mosConfig_live_site.'/administrator/components/com_realestatemanager/includes/realestatemanager.css' );
	?>
		<div class="componentheading<?php echo $params->get( 'pageclass_sfx' ); ?>">
			<?php echo $currentcat->header; ?>
		</div>

		<table border="0" cellpadding="4" cellspacing="0" width="100%" class="basictable">
			<tr>				
				<?php
				if($currentcat->img != null && $currentcat->align == 'left')
        {
				 ?>
				<td>
           <img src="<?php echo $currentcat->img; ?>" align="<?php echo $currentcat->align; ?>" />
        </td>
		         <?php
				}
				?>
				<td width="100%">
				  <?php echo $currentcat->descrip; ?>
				</td>
		         <?php
					if($currentcat->img != null && $currentcat->align == 'right')
          {
				?>
				 <td>
		       <img src="<?php echo $currentcat->img; ?>" align="<?php echo $currentcat->align; ?>"  alt = "?"/>       
         </td>
    <?php
				}
				?>
      </tr>
    </table>


<script type="text/javascript">
function showDate()
  {
//if(document.adminForm.search_date_from.type=="hidden" )
if(document.adminForm.search_date_box.checked )
{
var x=document.getElementById("search_date_from");
document.adminForm.search_date_from.type="text";

var x=document.getElementById("search_date_until");
document.adminForm.search_date_until.type="text";

}
else
{
var x=document.getElementById("search_date_from");
document.adminForm.search_date_from.type="hidden";

var x=document.getElementById("search_date_until");
document.adminForm.search_date_until.type="hidden";}
}
</script>


    <form action="<?php echo sefRelToAbs("index.php"); ?>" method="get" name="userForm1">
        <input type="hidden" name="option" value="<?php echo $option; ?>" />
        <input type="hidden" name="Itemid" value="<?php echo $Itemid; ?>" />
        <input type="hidden" name="task" value="search" />

        <table border="0" cellpadding="4" cellspacing="0" class="basictable" >
            <tr>
                <td align="right" colspan="2" nowrap>
                    <?php echo _REALESTATE_MANAGER_LABEL_SEARCH_KEYWORD; ?>&nbsp;
                </td>
                <td align="left" colspan="1" nowrap>
                    <input class="inputbox" type="text" name="searchtext" size="15" maxlength="20"/>
                </td>
                <td align="left" colspan="1">
                    <input type="submit" name="submit" value="<?php echo _REALESTATE_MANAGER_LABEL_SEARCH_BUTTON;?>" class="button" />
                </td>
            </tr>
            <tr> 
                 <td align="left" colspan="1" nowrap>
            <?php echo _REALESTATE_MANAGER_LABEL_CATEGORY; ?>&nbsp;

                </td>
                <td align="left" colspan="2" nowrap>
                                 <?php echo $clist; ?>
                </td>


            </tr>
            <tr>
                <td  align="right" colspan="2" nowrap>
                </td>
            </tr>
         </table> 
           
                 <input type="hidden" name= "address" id="Address" value="on" />
                 <input type="hidden"  name= "title" id="Taitle" value="on" />
                 <input type="hidden"  name="broker" id="Broker" value="on" />
                 <input type="hidden"  name= "feature" id="Feature"  value="on" />
                 <input type="hidden"  name= "area" id="Area" value="on"  />
                 <input type="hidden" name= "description" id="Description" value="on" />
                 <input type="hidden" name="houseid" value="on" />
                 <input type="hidden"  name=  "agent" id= "Agent" value="on"  />
                 <input type="hidden" name="ownername" value="on" />
                 <input type="hidden"  name=  "model" id= "Model" value="on"  />
      <br />       
    </form>
    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="basictable">
        <tr>
            <td width="50%">&nbsp;
            </td>
            <td width="50%">
          <?php
              mosHTML::BackButton($params, $hide_js);
          ?>
            </td>
        </tr>
    </table>  
<?php /*?><div style="text-align: center;"><a href="http://ordasoft.com" style="font-size: 10px;">Powered by OrdaSoft!</a></div><?php */?>
<?php
}



	function showRentRequestThanks( $params, $currentcat){
		global $hide_js, $Itemid, $catid, $doc, $mosConfig_live_site;
    $doc->addStyleSheet($mosConfig_live_site.'/administrator/components/com_realestatemanager/includes/realestatemanager.css');
	?>
	<div class="componentheading<?php echo $params->get( 'pageclass_sfx' ); ?>">
	   <?php echo $currentcat->header; ?>
	</div>
	<table border="0" cellpadding="4" cellspacing="0" width="100%" class="basictable">
			<tr>				
			  <?php
			    if($currentcat->img != null )
                             {
			  ?>
			     <td>
		        	<img src="<?php echo $currentcat->img; ?>" alt="?" />
		             </td>
		        <?php
				}
				?>
			     <td width="100%">
			       <?php echo $currentcat->descrip; ?>
			     </td>  
		     </tr>
	    </table>
		<form action="<?php if($catid==0) echo sefRelToAbs('index.php?option=com_realestatemanager&amp;Itemid='.$Itemid);   
                            else if($_REQUEST['where'] == 2) echo sefRelToAbs("index.php?option=com_realestatemanager&amp;task=showCategory&amp;catid=".$catid."&amp;Itemid=".$Itemid);
                            else echo sefRelToAbs("index.php?option=com_realestatemanager&amp;Itemid=".$Itemid);?>" method="post" name="userForm">
			<table border="0" cellpadding="4" cellspacing="0" width="100%" class="basictable" >
		      	<tr>
			   <td colspan="2" align="right">&nbsp;
			   </td>
		      	</tr>
		      	<tr>
			  <td>
			  </td>
			  <td>
			   <input type="submit" name="submit" value="<?php echo _REALESTATE_MANAGER_LABEL_OK; ?>" class="button" />
			  </td>
		      	</tr>
		    </table>			
		</form>
<?php
	}
}
